It will be remarked dirty.
FIXME: to be tracked. */
fprintf(stderr, "cannot map page %lx: %s\n",
- page_array[N], strerror (errno));
+ page_array[N], safe_strerror(errno));
continue;
}
bytes = write(da->fd, &buffer[offset], length-offset);
if ( bytes <= 0 )
{
- PERROR("Failed to write buffer: %s", strerror(errno));
+ PERROR("Failed to write buffer");
return -errno;
}
}
if ( (da.fd = open(corename, O_CREAT|O_RDWR, S_IWUSR|S_IRUSR)) < 0 )
{
- PERROR("Could not open corefile %s: %s", corename, strerror(errno));
+ PERROR("Could not open corefile %s", corename);
return -errno;
}
/* shared_info page starts its life empty. */
shared_info = xc_map_foreign_range(
xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
- printf("shared_info = %p, err=%s frame=%lx\n",
- shared_info, strerror (errno), shared_info_frame);
+ printf("shared_info = %p frame=%lx\n",
+ shared_info, shared_info_frame);
//memset(shared_info, 0, PAGE_SIZE);
/* Mask all upcalls... */
for ( i = 0; i < MAX_VIRT_CPUS; i++ )
return new_mfn;
}
+char *safe_strerror(int errcode)
+{
+ static __thread char errbuf[32];
+#ifdef __GLIBC__
+ /* Broken GNU definition of strerror_r may not use our supplied buffer. */
+ return strerror_r(errcode, errbuf, sizeof(errbuf));
+#else
+ /* Assume we have the POSIX definition of strerror_r. */
+ strerror_r(errcode, errbuf, sizeof(errbuf));
+ return errbuf;
+#endif
+}
+
/*
* Local variables:
* mode: C
#define PPRINTF(_f, _a...)
#endif
+char *safe_strerror(int errcode);
void xc_set_error(int code, const char *fmt, ...);
#define ERROR(_m, _a...) xc_set_error(XC_INTERNAL_ERROR, _m , ## _a )
#define PERROR(_m, _a...) xc_set_error(XC_INTERNAL_ERROR, _m " (%d = %s)", \
- ## _a , errno, strerror(errno))
+ ## _a , errno, safe_strerror(errno))
int lock_pages(void *addr, size_t len);
void unlock_pages(void *addr, size_t len);